/**
 *
 */
package cn.dw.sg.controller;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.apache.commons.beanutils.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;

import cn.dw.sg.aop.LogAnnotation;
import cn.dw.sg.domain.Authority;
import cn.dw.sg.service.AuthorityService;

/**
 * @author aubrey
 * @date  上午11:27:13
 * 
 */
@Controller
@RequestMapping("/authority")
public class AuthorityController {
	
	@Autowired
	private AuthorityService authorityService;
	
	
	@RequestMapping("/add")
	@ResponseBody
	public String add(Authority authority) {
		authorityService.add(authority);
		return "success";
	}
	
	@RequestMapping("/delete")
	@ResponseBody
	public String delete(Authority authority) {
		authorityService.delete(authority.getId());
		return "删除成功";
	}
	
	@RequestMapping("/query")
	@ResponseBody
	public List<Authority> query(Authority authority) {
		List<Authority> results = authorityService.query(authority);
//		JSONObject json = new JSONObject();
//		json.put("result", results);
		
		return results;
	}
	
	@RequestMapping("/update")
	@ResponseBody
	public String update(Authority authority) {
		authorityService.update(authority);
		return "success";
	}
	
	
	
	@RequestMapping("/testjsp")
	public String testJsp() {
		return "hello";
	}
}
